package org.csu.onlineedubackend.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.csu.onlineedubackend.entity.ForumTag;
import org.csu.onlineedubackend.mapper.ForumTagMapper;
import org.csu.onlineedubackend.service.ForumTagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class ForumTagServiceImpl implements ForumTagService {
    @Autowired
    private ForumTagMapper forumTagMapper;

    @Override
    public List<ForumTag> getAllTags() {
        return forumTagMapper.selectList(null);
    }

    @Override
    public int getPostCountByTag(Integer tagId) {
        ForumTag tag = forumTagMapper.selectById(tagId);
        return tag != null ? tag.getPostCount() : 0;
    }

    @Override
    public boolean createTag(ForumTag tag) {
        return forumTagMapper.insert(tag) > 0;
    }

    @Override
    public boolean updateTag(ForumTag tag) {
        return forumTagMapper.updateById(tag) > 0;
    }

    @Override
    public boolean deleteTag(Integer tagId) {
        return forumTagMapper.deleteById(tagId) > 0;
    }
} 